#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

const unsigned  int MAX_LINES_COUNT = 10;
const unsigned int MAX_N = 100*1000;

int main() {
	vector<unsigned int> input;
	for (unsigned int i = 0; i < MAX_LINES_COUNT; ++i) {
		unsigned int tmp = 0;
		scanf("%d", &tmp);
		if (tmp == 0)
			break;
		input.push_back(tmp);
	}

	const unsigned int input_cnt = input.size();
	sort(input.begin(), input.end());
	const unsigned int max_input = *(input.rbegin());

	vector<unsigned int> a(max_input+2);
	a[0] = 0;
	a[1] = 1;

	
	const unsigned int max_i = (max_input < MAX_N) ? (max_input/2) : (MAX_N/2);
	for (unsigned int i = 1; i <= max_i; ++i) {
		a[2*i] = a[i];
		a[2*i+1] = a[i] + a[i+1];
	}

	/*printf("\n");
	for (unsigned int i = 0; i <= max_input; ++i) {
		printf("%d %d\n", i, a[i]);
	}
	printf("\n");*/

	for (unsigned int i = 0; i < input_cnt; ++i) {
		const unsigned int N = input[i];
		unsigned int max = 0;
		for (int j = 0; j <= N; ++j)
			if (a[j] > max)
				max = a[j];
		printf("%d\n", max);
	}
}
